import axios from 'axios';
import type { UserDto, UserInfo, UserParam, UserVo } from "@/types/modules/system";
import type { Pageable, Pagination } from "@/types/global";

const contentPath = '/system/user'

export function create(user: UserDto) {
  return axios.post<boolean>(`${contentPath}`, user)
}

export function update(user: UserDto) {
  return axios.put<boolean>(`${contentPath}`, user)
}

export function deleteById(id: number) {
  return axios.delete<boolean>(`${contentPath}/${id}`)
}

export function findUserInfo() {
  return axios.get<UserInfo>('/system/self/info')
}

export function findById(id: number) {
  return axios.get<UserVo>(`${contentPath}/${id}`)
}

export function listWithPagination(pageable: Pageable, param: UserParam) {
  return axios.get<Pagination<UserVo>>(`${contentPath}/pagination`, {
    params: {
      ...pageable,
      ...param
    }
  })
}
